The Design of The NAG Toolbox for MATLAB®The first section of this document describes the structure of the Toolbox and its documentation, and should be of interest to all users. The second part, Comparison with the Fortran Library, is mainly of interest to users familiar with using NAG routines directly. Structure of the ToolboxThe Toolbox has the same structure as the NAG Library. The Library is divided into chapters, each devoted to a branch of numerical analysis or statistics. Each chapter has a three-character name and a title, e.g.,
All documented routines in the Toolbox have five-character names, beginning with the characters of the chapter name, e.g.,
The documentation of the Toolbox follows the same chapter structure as the Library, so each chapter of routines has a corresponding chapter in the documentation, consisting of the following documents:
Comparison with the Fortran LibraryThis section will mainly be of interest to users familiar with using the NAG Library directly from Fortran or another high-level programming environment. It explains the rationale for deciding whether a parameter is optional or omitted from the interface completely, and other differences between the Library and the Toolbox.Optional ParametersOptional parameters fall into one of the following categories:
Parameters Omitted from the Toolbox InterfaceThe following kinds of parameters have been omitted completely from the toolbox interface, because they can always be determined at runtime:
User WorkspaceMany routines have parameters for user workspace, which are passed unchanged to user-supplied functions or subroutines. This allows data to be passed to these subprograms in a thread-safe way. Typically there are two or three such parameters, an integer and real array and, sometimes, a character array. In the MATLAB toolbox these are replaced by a single MATLAB object, to provide more flexibility. For example in the following case user is a cell array containing three pieces of data:x = [0.5; 1; 1.5]; y = [0.14,0.18,0.22,0.25,0.29,0.32,0.35,0.39,0.37,0.58,0.73,0.96,1.34,2.10,4.39]; t = [[1.0, 15.0, 1.0], [2.0, 14.0, 2.0], [3.0, 13.0, 3.0], [4.0, 12.0, 4.0], [5.0, 11.0, 5.0], [6.0, 10.0, 6.0], [7.0, 9.0, 7.0], [8.0, 8.0, 8.0], [9.0, 7.0, 7.0], [10.0, 6.0, 6.0], [11.0, 5.0, 5.0], [12.0, 4.0, 4.0], [13.0, 3.0, 3.0], [14.0, 2.0, 2.0], [15.0, 1.0, 1.0]]; user = {y, t, 3}; [xOut, fsumsq] = e04fy(int32(15), 'e04fy_lsfun1', x, 'iuser', user);It is used in the M-File e04fy_lsfun1.m as follows: function [fvecc, user] = lsfun1(m, n, xc, user) fvecc=zeros(m,1); % y is in user{1} and t is in user{2} for i = 1:m fvecc(i) = xc(1) + user{2}(i,1)/(xc(2)*user{2}(i,2)+xc(3)*user{2}(i,3))-... user{1}(i); end Input/Output ParametersIn the Fortran Library it is common for parameters to have their values over-written on exit from the routine. These routines are marked as Input/Output in the documentation. Since this behaviour seems unnatural in MATLAB, we have chosen to split parameters into Input and Output only.Routines Omitted from the ToolboxThe Toolbox contains interfaces to all the routines in Mark 21 of the NAG Fortran Library apart from chapter F06 (Linear Algebra Support Routines) and:
ReferencesACM (1960–1976) Collected algorithms from ACM index by subject to algorithms |
© Numerical Algorithms Group
Visit NAG on the web at:
www.nag.co.uk (Europe and ROW)
www.nag.com (North America)
www.nag-j.co.jp (Japan)
http://www.nag.co.uk/numeric/mb/design.asp